import type { AxiosRequestConfig, AxiosResponse, AxiosTransformer } from 'axios'
import type { Res } from '/@/tool/Res'

// import coreTool from '/@/tool/coreTool'
import coreAxios from '/@/tool/coreAxios'

const url: string = 'dirs'

const transformRequest: AxiosTransformer = (data) => {
  return data
}

const config: AxiosRequestConfig = {
  headers: {
    'Content-Type': 'multipart/form-data;charset=UTF-8'
  },
  transformRequest: transformRequest,
}

/**
 * 文件上传 REST API
 */
export default {
  /**
   * 文件上传
   * param 参数
   */
  fileUpload(param: FormData): Promise<AxiosResponse<Res<string>>> {
    return coreAxios.post<Res<string>>(`${url}/fileUpload`, param, config)
  },
}
